package main

import (
	. "action"
	. "etrgo"
	"net/http"
)

func main() {
	Info("loading configure file etrgo.conf")
	Configuration.Init("D:\\webproject\\etrgo\\src\\etrgo.conf")

	Info("db_str:%s", Configuration.DbConf.ConStr)

	b := FuncMap{"/adm": AuthFilter}

	a := FuncMap{"^/?$": Index,
		"/nag/scode":       SecurityCodeAction,
		"/adm/main":        MainAction,
		"/entry":           EntryAction,
		"/login":           LoginAction,
		"/item":            ShowOneProduct,
		"/adm/pic/del":     DeletePicture,
		"/adm/pic/chg":     ChgPictureOrder,
		"/adm/prod/list":   ListProdAction,
		"/adm/prod/index":  NewProd,
		"/adm/prod/edit":   EditProdAction,
		"/adm/prod/upload": UploadPicture,
		"/adm/prod/save":   SaveProd,
		"/adm/prod/priority": SetPriorityAction,
		"/img":             ImgAction,
	}

	AppRouter.SetTemplateDir(Configuration.TemplateDir)
	AppRouter.AddHandler(a)
	AppRouter.AddFilter(b)

	AppRouter.SetStaticPath("/css,/static,/js,/img")
	err := http.ListenAndServe(":80", AppRouter)
	if err != nil {
		Error("ListenAndServe: ", err.Error())
	}
}
